package pers.vic.quartz.controller;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import pers.vic.boot.base.controller.BaseController;
import pers.vic.boot.base.model.BaseResponse;
import pers.vic.boot.base.vo.BooleanWithMsg;
import pers.vic.quartz.model.QuartzTaskJob;
import pers.vic.quartz.service.QuartzTaskJobService;

/**
 * @description:定时任务 控制层
 * @author Vic.xu
 * @date: 2022-04-13
 */
@RestController
@RequestMapping("/quartz/taskJob")
public class BlogTaskJobController extends BaseController<QuartzTaskJobService, QuartzTaskJob> {


    /**
     * 操作定时任务 运行/暂停/删除
     * @return
     */
    @RequestMapping("/operate")
    public BaseResponse<?> operate(int id, int status) {
        BooleanWithMsg msg = service.operate(id, status);
        return BaseResponse.judge(msg.isSuccess()).setMsg(msg.getMessage());
    }


    /**
     * 立即执行任务
     * @return
     */
    @RequestMapping("/runJob")
    public BaseResponse<?> runJob(int id) {
        BooleanWithMsg msg = service.runJob(id);
        return BaseResponse.judge(msg.isSuccess()).setMsg(msg.getMessage());
    }


}
